package ru.paswd.marketprice.ui.widgets.chart.impl.philjay

import com.github.mikephil.charting.formatter.ValueFormatter
import java.util.*

class PriceHistoryValueFormatter : ValueFormatter() {
    override fun getFormattedValue(value: Float): String {
        val calendar = Calendar.getInstance()
        calendar.timeInMillis = value.toLong()
        return "${calendar.get(Calendar.DAY_OF_MONTH)} ${getMonth(calendar.get(Calendar.MONTH))}"
    }

    private fun getMonth(calendarMonth: Int) = when (calendarMonth) {
        Calendar.JANUARY -> "янв"
        Calendar.FEBRUARY -> "фев"
        Calendar.MARCH -> "мар"
        Calendar.APRIL -> "апр"
        Calendar.MAY -> "май"
        Calendar.JUNE -> "июн"
        Calendar.JULY -> "июл"
        Calendar.AUGUST -> "авг"
        Calendar.SEPTEMBER -> "сен"
        Calendar.OCTOBER -> "окт"
        Calendar.NOVEMBER -> "ноя"
        Calendar.DECEMBER -> "дек"
        else -> ""
    }
}